//
//  ButtonView.m
//  Funny
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 King. All rights reserved.
//

#import "ButtonView.h"

@implementation ButtonView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatButton];
        
        self.hotView = [[UIImageView alloc]init];
        [self addSubview:self.hotView];
        [self.hotView setImage:[UIImage imageNamed:@"jieshao.png"]];
        
        self.introduceView = [[UIImageView alloc]init];
        [self addSubview:self.introduceView];
        [self.introduceView setImage:[UIImage imageNamed:@"hot.png"]];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.hotView.frame = CGRectMake(30, 18, 25, 25);
    self.introduceView.frame = CGRectMake(SelfWidth / 2 + 20, 18, 25, 25);
}

- (void)creatButton
{
    NSArray *nameArr = @[@"城市介绍",@"热门推荐"];
    for (int i = 0; i < 2; i++) {
        UIButton *button = [UIButton buttonWithFrame:CGRectMake(SelfWidth / 2 * i + 15, 6, SelfWidth / 2 - 2, 50) color:nil title:nameArr[i] type:UIButtonTypeSystem target:self action:@selector(ActionClick:) event:UIControlEventTouchUpInside cornerRadius:0];
        button.tintColor = [UIColor whiteColor];
        button.tag = 20 + i;
        button.titleLabel.font = [UIFont systemFontOfSize:20];
        [self addSubview:button];
        button.tag = 20 + i;
    }
}

- (void)ActionClick:(UIButton *)btn
{
    if (btn.tag == 20) {
        [self.delegate pushToNext];
    }
    if (btn.tag == 21) {
        [self.delegate pushToRecommend];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
